package service

import (
	"context"
	"github.com/cloudwego/hertz/pkg/app"
	user "userapi/hertz_gen/user"
	rpcmodel "userrpc/kitex_gen/user"
	"userrpc/rpc"
)

type RegisterUserService struct {
	RequestContext *app.RequestContext
	Context        context.Context
}

func NewRegisterUserService(Context context.Context, RequestContext *app.RequestContext) *RegisterUserService {
	return &RegisterUserService{RequestContext: RequestContext, Context: Context}
}

func (h *RegisterUserService) Run(req *user.User) (resp *user.Response, err error) {
	//defer func() {
	// hlog.CtxInfof(h.Context, "req = %+v", req)
	// hlog.CtxInfof(h.Context, "resp = %+v", resp)
	//}()
	// todo edit your code
	r, err := rpc.Client().RegisterUser(h.Context, &rpcmodel.User{})
	if err != nil {
		return nil, err
	}
	return &user.Response{Message: r.Message}, nil
}
